<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title></title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
		<link rel="stylesheet" href="../../../../layuiadmin/layui/css/layui.css" media="all">
		<link rel="stylesheet" href="../../../../layuiadmin/style/admin.css" media="all">
		<link rel="stylesheet" href="../../../../css/common.css" media="all">
		<style>
			.layui-form-label{
			    white-space: nowrap;
				display: flex;
				justify-content: flex-end;
			}
		</style>
	</head>

	<body>

		<div class="layui-fluid">
			<div class="layui-row" id="view">
				<form class="layui-form" lay-filter="test_detail">
					<div class="layui-card">
						<div class="layui-card-body">

							<div class="layui-form-item">
								<label class="layui-form-label">商品编号<!-- <span style="color:red">*</span> --></label>
								<div class="layui-input-inline">
									<!-- <input type="text" name="skuid" disabled lay-verify="required" placeholder="请选择商品编号" autocomplete="off" class="layui-input skuid"> -->
									<div class="layui-form-mid layui-word-aux">
										<span id="shopCode" style="color: #000;"></span>
									</div>
								</div>
								<!-- <div class="layui-form-mid layui-word-aux">
									<a href="Javascript:;" onclick="searchdata('skuid')">选择</a>
								</div> -->
							</div>

							<div class="layui-form-item">
								<label class="layui-form-label">开始日期<!-- <span style="color:red">*</span> --></label>
								<div class="layui-input-inline">
									<!-- <input type="text" name="dates" lay-verify="required" placeholder=" " autocomplete="off" class="layui-input seckill_id" readonly> -->
									<div class="layui-form-mid layui-word-aux">
										<span id="dates" style="color: #000;"></span>
									</div>
								</div>
								<label class="layui-form-label">开始时间<!-- <span style="color:red">*</span> --></label>
								<div class="layui-input-inline">
									<!-- <input type="text" name="times" lay-verify="required" placeholder=" " autocomplete="off" class="layui-input seckill_id" readonly> -->
									<div class="layui-form-mid layui-word-aux">
										<span id="times" style="color: #000;"></span>
									</div>
								</div>
							</div>
							<!-- <div class="layui-form-item">
								<label class="layui-form-label">结束时间<span style="color:red">*</span></label>
								<div class="layui-input-inline">
									<input type="text" name="endtime"  placeholder=" " autocomplete="off" class="layui-input limited_name" readonly>
									<input type="hidden" name="seckill_id" lay-verify="required" placeholder="" autocomplete="off" class="layui-input seckill_id" readonly>
								</div>
								<div class="layui-form-mid layui-word-aux">
									<a href="Javascript:;" onclick="searchdata('seckill_id')">选择</a>
								</div>
							</div> -->

							<div class="layui-form-item">
								<label class="layui-form-label">团购价<span style="color:red">*</span></label>
								<div class="layui-input-block">
									<input type="text" name="price" lay-verify="required" placeholder="请输入团购价格(保留小数点后两位）" autocomplete="off" class="layui-input">
								</div>
							</div>
							
<!-- 						<div class="layui-form-item">
								<div class="layui-inline">
									<label class="layui-form-label">积分抵扣</label>
									<div class="layui-input-inline">
										<input type="text" name="score_scale" placeholder="请输入积分抵扣百分比" autocomplete="off" class="layui-input">
									 
									</div>
								</div>
								<div class="layui-inline">
									<label class="layui-form-label">积分</label>
									<div class="layui-input-inline">
										<input type="text" name="score" placeholder="请输入积分抵扣" autocomplete="off" class="layui-input">
									 
									</div>
								</div> 
							</div> -->
							
							<div class="layui-form-item">
								<label class="layui-form-label">补贴<span style="color:red">*</span></label>
								<div class="layui-input-block">
									<input type="text" name="subsidy" lay-verify="required" placeholder="请输入补贴" autocomplete="off" class="layui-input">
								</div>
							</div>
							
							<div class="layui-form-item">
								<label class="layui-form-label">团人数<span style="color:red">*</span></label>
								<div class="layui-input-block">
									<input type="text" name="group_num" lay-verify="required" placeholder="请输入团人数" autocomplete="off" class="layui-input">
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">中奖人数<span style="color:red">*</span></label>
								<div class="layui-input-block">
									<input type="text" name="group_wnum"  lay-verify="required"  placeholder="请输入中奖人数" autocomplete="off" class="layui-input">
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">显示已参团人数<span style="visibility: hidden;">*</span></label>
								<div class="layui-input-block">
									<input type="text" name="group_onum"  placeholder="请输入已参团人数" autocomplete="off" class="layui-input">
								</div>
							</div>
							
							<div class="layui-form-item">
								<label class="layui-form-label">活动数量<span style="color:red">*</span></label>
								<div class="layui-input-block">
									<input type="text" name="stock" lay-verify="required" placeholder="请输入库存数量" autocomplete="off" class="layui-input">
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">显示已购数量</label>
								<div class="layui-input-block">
									<input type="text" name="sales"  placeholder="请输入已购买数量" autocomplete="off" class="layui-input">
								</div>
							</div>
							
							
							<div class="layui-form-item">
								<label class="layui-form-label">显示数量<span style="color:red">*</span></label>
								<div class="layui-input-block">
									<input type="text" name="num"  placeholder="显示数量" autocomplete="off" class="layui-input">
								</div>
							</div>
							
							<div class="layui-form-item">
								<label class="layui-form-label">单人购买上限<span style="color:red">*</span></label>
								<div class="layui-input-block">
									<input type="text" name="top_count"  placeholder="显示数量" autocomplete="off" class="layui-input">
								</div>
							</div>
							
							<div class="layui-form-item">
								<label class="layui-form-label">活动时长</label>
								<div class="layui-input-block">
									<input type="text" name="duration"  placeholder="请输入活动时长" autocomplete="off" class="layui-input">
								</div>
							</div>
							
							
							<div class="layui-form-item">
								<label class="layui-form-label">发起奖金<span style="color:red">*</span></label>
								<div class="layui-input-block">
									<input type="text" name="launch_fee" lay-verify="required" placeholder="请输入发起奖金" autocomplete="off" class="layui-input">
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">直推佣金<span style="color:red">*</span></label>
								<div class="layui-input-block">
									<input type="text" name="direct_fee" lay-verify="required" placeholder="请输入直推佣金" autocomplete="off" class="layui-input">
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">间推佣金<span style="color:red">*</span></label>
								<div class="layui-input-block">
									<input type="text" name="indirect_fee" lay-verify="required" placeholder="请输入间推佣金" autocomplete="off" class="layui-input">
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">团长佣金<span style="color:red">*</span></label>
								<div class="layui-input-block">
									<input type="text" name="leader_fee" lay-verify="required" placeholder="请输入团长佣金" autocomplete="off" class="layui-input">
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">管理奖<span style="color:red">*</span></label>
								<div class="layui-input-block">
									<input type="text" name="team_fee" lay-verify="required" placeholder="请输入管理奖" autocomplete="off" class="layui-input">
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">合伙人佣金<span style="color:red">*</span></label>
								<div class="layui-input-block">
									<input type="text" name="copartner_fee" lay-verify="required" placeholder="请输入合伙人佣金" autocomplete="off" class="layui-input">
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">服务站佣金<span style="color:red">*</span></label>
								<div class="layui-input-block">
									<input type="text" name="station_fee" lay-verify="required" placeholder="请输入服务站佣金" autocomplete="off" class="layui-input">
								</div>
							</div>
							
							<div class="layui-form-item">
								<label class="layui-form-label">排序<span style="color:red">*</span></label>
								<div class="layui-input-block">
									<input type="number" name="oid" placeholder="排序" autocomplete="off" class="layui-input number">
								</div>
							</div>

						</div>
					</div>
					<div class="layui-form-item layui-layout-admin">
						<div class="layui-input-block">
							<div class="layui-footer" style="left: 0;">
								<button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
							</div>
						</div>
					</div>
				</form>
			</div>
		</div>
		<script src="../../../../layuiadmin/layui/layui.js"></script>
		<script src="../../../../js/jquery.min.js"></script>
		<script src="../../../../js/jquery.jqprint-0.3.js"></script>
		<script src="../../../../js/common.js"></script>
		<script>
			var _data = {
				id: getParam('id')
			}
			layui.config({
				base: '../../../../layuiadmin/' //静态资源所在路径
			}).extend({
				index: 'lib/index' //主入口模块
			}).use(['index', 'form'], function() {
				var $ = layui.$,
					admin = layui.admin,
					form = layui.form;

				if(_data.id) {
					initdata();
				}

				//监听提交
				form.on('submit(demo1)', function(data) {
					var data = data.field;
					_data = Object.assign(_data, data);
					layer.confirm('确定要提交数据？', function() {
						loading();
						if(_data.id) {
							submitdata(server.seckill_goods_edit);
						} else {
							delete _data.id
							//submitdata(server.limited_goods_insert);
						}
					}, function() {
						layer.msg('取消操作');
					});
					return false;
				});

				function submitdata(_url) {
					$.post(_url, _data, function(res, status) {
						if(status == 'success') {
							if(res.code == 0) {
								layer.alert('操作成功', function() {
									parent.layer.closeAll();
									parent.layui.table.reload('test-table-operate');
								});
							} else {
								layer.msg(res.msg);
							}
							closeloading();
						} else {
							closeloading();
							layer.msg('服务器连接错误');
						}
					});
				}

				window.searchdata = function(type) {
					switch(type) {
						case 'skuid':
							layer.open({
								type: 2,
								title: '选择',
								shadeClose: false,
								shade: 0.5,
								maxmin: true, //开启最大化最小化按钮
								area: ['800px', '98%'],
								content: 'choose_skuid.html',
								end: function() {},
								success: function() {}
							});
							break;
						case 'seckill_id':
							layer.open({
								type: 2,
								title: '选择',
								shadeClose: false,
								shade: 0.5,
								maxmin: true, //开启最大化最小化按钮
								area: ['800px', '90%'],
								content: 'choose_limited.html',
								end: function() {},
								success: function() {}
							});
							break;
					}
				}

				function initdata() {
					$.get(server.seckill_goods_detail, _data, function(res, status) {
						if(status == 'success') {
							if(res.code == 0) {
								var data = res.seckill_goods
								console.log(data, 'data')
								let skuidEl = document.getElementById('shopCode')
								skuidEl.innerHTML = data.data.skuid
								let datesEl = document.getElementById('dates')
								datesEl.innerHTML = data.data.dates
								let timesEl = document.getElementById('times')
								timesEl.innerHTML = data.data.times
								form.val("test_detail", data.data);
								form.render();
							} else {
								layer.msg(res.msg);
							}
						} else {
							layer.msg('服务器连接错误');
						}
					});
				}
				
				// $("input[name=score]").bind("blur",function(e){
				// 	var market_price = $("input[name=price]").val()
				// 	var score = $("input[name=score]").val()
				// 	console.log(market_price)
				// 	console.log(score)
				// 	if (score> 0 &&  market_price>0) {
				// 		var sumScale = Math.round(parseFloat((score/market_price).toFixed(2)) * 100)  
				// 		$("input[name=score_scale]").val(sumScale)
				// 	}
				// })
				// $("input[name=score_scale]").bind("blur",function(e){
				// 	var market_price = $("input[name=price]").val()
				// 	var score_scale = $("input[name=score_scale]").val()
				// 	if (score_scale >0 &&  score_scale <=100 && market_price>0 ) {
				// 		var sumScore = Math.round(parseFloat((market_price*score_scale).toFixed(2)) * 100) /10000
				// 		$("input[name=score]").val(sumScore)
				// 	}
				// })
			});
		</script>
	</body>

</html>